package message

import (
	"github.com/axgle/mahonia"
	"hy_808/protocol/hygprs"
)

/*
自定义短信
+0  A0 00 2B 02 00 06 A9
+7  01 00 00 00 34
+12 02 00 00 00 6F
+17 13 00 01 86 A1
+22 06 62 1C 3E 26
+27 12 D3 D6 D6 D8 C6 F4 C1 CB A3 BF 短信内容 GBK编码 又重启了?
-5  00 00 0C 56 A1
-0
*/
type CustomMessage struct {
	hygprs.Fields
}

func MakeCustomMessage(p hygprs.Fields) CustomMessage {
	return CustomMessage{p}
}

func (p CustomMessage) Content() []byte {
	return p.Data[28 : len(p.Data)-5]
}

func (p CustomMessage) ContentString() string {
	return mahonia.NewDecoder("GBK").ConvertString(string(p.Content()))
}
